/**
 * TestMotionEventActivity.java
 * classes: com.hymobile.common.activity.TestMotionEventActivity
 * 梁天刚 created at 2011-11-30 下午3:11:17
 */
package com.wzz.common.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

import com.hymobile.common.R;
import com.wzz.common.animation.MScaleAnimation;
import com.wzz.common.animation.MTranslateAnimation;

/**
 * com.hymobile.common.activity.TestMotionEventActivity
 * 
 * @author 梁天刚
 * 
 *         created at 2011-11-30 下午3:11:17
 */
public class TestAnimationActivity extends Activity {


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.testanimation);
  }

  public void onMTranslate(View v) {
    //从当前位置移动到父控件左边
    MTranslateAnimation tr = new MTranslateAnimation(1, 0, 2, 0, 0, 0, 0, 0);
    tr.setLeftTop(v.getLeft(), v.getTop());
    tr.setDuration(1800);
    v.startAnimation(tr);
  }

  public void onMScale(View v) {
    MScaleAnimation scale = new MScaleAnimation(1, 0.5f, 1, 0.5f, 2, 0.5f, 2, 0.5f);
    scale.setDuration(1800);
    scale.setLeftTop(v.getLeft(), v.getTop());
    v.startAnimation(scale);
  }

  public void onTranslate(View v) {
    //从当前位置移动到父控件左边
    TranslateAnimation tr = new TranslateAnimation(1, 0, 2, 0, 0, 0, 0, 0);
    tr.setDuration(1800);
    v.startAnimation(tr);
  }

  public void onScale(View v) {
    //宽高各缩小0.5 以父控件中心为中心
    ScaleAnimation scale = new ScaleAnimation(1, 0.5f, 1, 0.5f, 2, 0.5f, 2, 0.5f);
    scale.setDuration(1800);
    v.startAnimation(scale);
  }
  
  public void onMTranslate2(View v) {
    //从当前位置移动到父控件右边0.5
    MTranslateAnimation tr = new MTranslateAnimation(1, 0, 2, 0.5f, 0, 0, 0, 0);
    tr.setLeftTop(v.getLeft(), v.getTop());
    tr.setDuration(1800);
    v.startAnimation(tr);
  }

  public void onMScale2(View v) {
    //宽高各缩小0.5 以父控件中心为中心
    MScaleAnimation scale = new MScaleAnimation(1, 0.5f, 1, 0.5f, 2, 0.5f, 2, 0.5f);
    scale.setDuration(1800);
    scale.setLeftTop(v.getLeft(), v.getTop());
    v.startAnimation(scale);
  }

  public void onTranslate2(View v) {
    //从当前位置移动到父控件右边0.5
    TranslateAnimation tr = new TranslateAnimation(1, 0, 2, 0.5f, 0, 0, 0, 0);
    tr.setDuration(1800);
    v.startAnimation(tr);
  }

  public void onScale2(View v) {
    //宽高各缩小0.5 以父控件中心为中心
    ScaleAnimation scale = new ScaleAnimation(1, 0.5f, 1, 0.5f, 2, 0.5f, 2, 0.5f);
    scale.setDuration(1800);
    v.startAnimation(scale);
  }

}
